package com.sayi.api

import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.ui.Model
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController

@SpringBootApplication
class ApiApplication

fun main(args: Array<String>) {
	runApplication<ApiApplication>(*args)
}
@Controller
class TestController {

    /**
     * 访问 hello 跳转到 index 页面
     * @param model
     * @return
     */
    @GetMapping("/hello")
    fun hello(model: Model): String {
        model.addAttribute("hello", "hello welcome")
        return "index"
    }
	@RestController
	class MsgController{
		@GetMapping("/")
		fun index():String {
			return "Hello, world!"
		}
		@GetMapping("/hi")
		fun hi(@RequestParam("name") name: String):String {
			return "Hello, $name!"
		}
	}
}